package cn.edu.ljl;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;

//通过接收ID号，实现对学习建议信息的删除
//删除后到进入学习建议展示界面，使用listExperience

public class deleteSearch extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doPost(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response )throws ServletException, IOException {
        request.setCharacterEncoding("UTF-8");
        String id = request.getParameter("id");
        System.out.println(id);
        String sql = "DELETE FROM courses WHERE id=" + id;
        System.out.println(sql);

        try {
            DBMS.delete(sql);
            response.sendRedirect("./listExperience");
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
